<template>
	<view class="mainbgc mainpadding">
		<header-top :messageInfo="{typeFlag:true,message:'盘点库存',liner:false}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content">
					<view class="nostrongtext" @click="surebtn">确定</view>
				</view>
			</view>
		</header-top>
		<view class="mainpadding ffffff margin_top">
			<view class="flexbetween">
				<view class="titletext">{{dataAll.goodsinfo.name}}</view>
				<view class="huisetext">库存：{{dataAll.total_stock}}</view>
			</view>
			<view class="flexleft margin_top" @click="shengchang()" v-if="dataAll.goodsinfo.producedate_status==1">
				<view class="huisetext">生产日期：</view>
				<input type="text" class="inputs xiabiank" placeholder="无生产日期" disabled="" v-model="dataAll.produce_time_text">
			</view>
			<view class="biaoti margin_top">盘点库存：</view>
			<view class="flexleft margin_top">
				<view class="flexleft" v-show="dataAll.goodsinfo.biggoodsunit.id">
					<input type="text" class="input" v-model="dataAll.big_unit_stock">
					<view class="biaoti" style="margin: 0 10rpx;">{{dataAll.goodsinfo.biggoodsunit.name}}</view>
				</view>
				<view class="flexleft" v-show="dataAll.goodsinfo.middlegoodsunit.id">
					<input type="text" class="input" v-model="dataAll.middle_unit_stock">
					<view class="biaoti" style="margin: 0 10rpx;">{{dataAll.goodsinfo.middlegoodsunit.name}}</view>
				</view>
				<view class="flexleft" v-show="dataAll.goodsinfo.smallgoodsunit.id">
					<input type="text" class="input" v-model="dataAll.small_unit_stock">
					<view class="biaoti" style="margin: 0 10rpx;">{{dataAll.goodsinfo.smallgoodsunit.name}}</view>
				</view>
			</view>
		</view>
		<u-datetime-picker :show="timeshow" mode="date" v-model="value1" @confirm="timersure" @cancel="timeshow=false">
		</u-datetime-picker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				timeshow: false,
				value1: Number(new Date()),
				listid:"",
				dataAll:{}
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
		},
		methods: {
			// 盘点商品详情
			init() {
				httpRequest.request('/dhtapi/Warehouse/pdGoodsDetail', 'POST', {
					id: this.listid
				}, false, false, true).then(res => {
					if (res.code == 1) {
						res.data.big_unit_stock = res.data.big_unit_stock==-1?"":res.data.big_unit_stock
						res.data.middle_unit_stock = res.data.middle_unit_stock==-1?"":res.data.middle_unit_stock
						res.data.small_unit_stock = res.data.small_unit_stock==-1?"":res.data.small_unit_stock
						this.dataAll = res.data
					}
				})
			},
			// 编辑
			surebtn(){
				httpRequest.request('/dhtapi/Warehouse/editPdGoods', 'POST', {
					id:this.listid,
					small_unit_stock:this.dataAll.small_unit_stock===""?-1:this.dataAll.small_unit_stock,
					middle_unit_stock:this.dataAll.middle_unit_stock===""?-1:this.dataAll.middle_unit_stock,
					big_unit_stock:this.dataAll.big_unit_stock===""?-1:this.dataAll.big_unit_stock,
					produce_time:this.dataAll.produce_time_text
				}, false, false, true).then(res => {
					if (res.code == 1) {
						httpRequest.toast(res.msg)
						setTimeout(function() {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			},
			//生产日期
			shengchang() {
				this.timeshow = true
			},
			timersure(e) {
				this.dataAll.produce_time_text = httpRequest.returnDate(e.value)
				this.timeshow = false
			},
			
			
		}
	}
</script>

<style lang="scss" scoped>
	// 底部
	.queding {
		margin: auto;
		width: 260rpx;
		height: 62rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0BBDCB;
		border-radius: 74rpx;
		border: 2rpx solid #0BBDCB;
	}
	
	.btoombox {
		position: fixed;
		width: 100%;
		padding: 30rpx 30rpx 70rpx;
		bottom: 0;
		left: 0;
		box-sizing: border-box;
	}
	
	.xiabiank {
		padding-bottom: 10rpx;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.03);
	}
	.inputs {
		width: 40%;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}
	.input {
		width: 144rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		height: 50rpx;
		text-align: center;
		background: rgba(0, 0, 0, 0.05);
		border-radius: 6rpx;
	}

	.biaoti {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
	}

	.neibianju {
		padding-bottom: 200rpx;
	}


	.huisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}
</style>
